package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.Downloading;

/**
 * 
 * @author 
 *
 */
@DAO
public interface DownloadDAO{
	
	@SQL("SELECT * FROM NewRanking WHERE 1=1  AND title=:t.title, AND content=:t.content, AND carouselImage=:t.carouselImage, AND orderNo=:t.orderNo, AND deleteFlag=:t.deleteFlag, AND createUser=:t.createUser, AND createAT=:t.createAT, AND updateUser=:t.updateUser, AND updateAT=:t.updateAT, ORDER BY updateAT DESC LIMIT :t.start,:t.end ")
    List<Downloading> query(@SQLParam("t") Downloading newRanking);
    
    @SQL("select * from NewRanking where id=:1")
    Downloading queryById(int id);
    
    @SQL("INSERT INTO NewRanking (title,content,carouselImage,orderNo,deleteFlag,createUser,createAT,updateUser,updateAT,type,upFile) VALUES (:t.title,:t.content,:t.carouselImage,:t.orderNo,:t.deleteFlag,:t.createUser,:t.createAT,:t.updateUser,:t.updateAT,:t.type,:t.upFile)")
    void create(@SQLParam("t") Downloading newRanking);
	
	@SQL("UPDATE NewRanking SET title=:t.title,content=:t.content,carouselImage=:t.carouselImage,orderNo=:t.orderNo,updateUser=:t.updateUser,updateAT=:t.updateAT,type=:t.type,upFile=:t.upFile WHERE id=:t.id")
    void update(@SQLParam("t") Downloading newRanking);
    
    @SQL("UPDATE NewRanking SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);

    @SQL("select id,title,type,content,orderNo from NewRanking where deleteFlag = 1 and type=:t.type #if(:t.title != ''){ and title like '%##(:t.title)%'} order by orderNo asc limit :t.start,:t.length")
	List<Downloading> getList(@SQLParam("t")Downloading newRanking);

    @SQL("select count(1) from NewRanking where deleteFlag = 1 and type=:t.type #if(:t.title != ''){ and title like '%##(:t.title)%'}")
	int getSize(@SQLParam("t")Downloading newRanking);
}